﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:framework="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
    xmlns:local="clr-namespace:CCWP7.CaliburnMicro"
    xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    xmlns:System="clr-namespace:System;assembly=mscorlib" 
    xmlns:behaviors="clr-namespace:CCWP7.CaliburnMicro.Behaviors"
    behaviors:TiltEffect.IsTiltEnabled="True"
    x:Class="CCWP7.CaliburnMicro.ServerPage"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <framework:AppBarButton IconUri="/icons/appbar.refresh.rest.png" Message="RefreshServerInfo" Text="refresh"/>
            <framework:AppBarButton IconUri="/icons/appbar.delete.rest.png" Message="RemoveServer" Text="remove"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="#FF3B8686">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="PageStates">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:0.5"/>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Normal">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(ProgressBar.IsIndeterminate)" Storyboard.TargetName="progressBar">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <System:Boolean>False</System:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="progressBar" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Refreshing">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(ProgressBar.IsIndeterminate)" Storyboard.TargetName="progressBar">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <System:Boolean>True</System:Boolean>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="progressBar" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <!--Pivot Control-->
        <controls:Pivot Title="{StaticResource AppTitle}">
            <!--Pivot item one-->
            <controls:PivotItem Header="server">
                <Grid>
                    <StackPanel>
                        <StackPanel Margin="0,12,0,12" behaviors:TiltEffect.IsTiltEnabled="True">
                            <Custom:Interaction.Triggers>
                                <Custom:EventTrigger EventName="Tap">
                                    <framework:ActionMessage MethodName="NavigateToServerUri"/>
                                </Custom:EventTrigger>
                            </Custom:Interaction.Triggers>

                            <TextBlock Text="Server Uri:" Style="{StaticResource PhoneTextNormalStyle}" />
                            <HyperlinkButton x:Name="ServerUri" Content="{Binding ServerUri}" HorizontalAlignment="Left"/>
                        </StackPanel>

                        <StackPanel Margin="0,12,0,12">
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}" Text="Last Refresh:" />
                            <TextBlock x:Name="LastRefresh" Style="{StaticResource PhoneTextAccentStyle}" Text="{Binding LastRefresh}" />
                        </StackPanel>

                        <StackPanel Margin="0,12,0,12">
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}" Text="Queues:" />
                            <ListBox x:Name="Queues" MinHeight="100" Margin="0,0,0,0" ItemsSource="{Binding Queues}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Name}" Style="{StaticResource PhoneTextSubtleStyle}" />
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </StackPanel>
                    </StackPanel>
                    <Rectangle HorizontalAlignment="Right" Height="150" Stroke="Black" VerticalAlignment="Bottom" Width="100" Fill="{StaticResource PhoneInactiveBrush}" Margin="7">
                        <Rectangle.OpacityMask>
                            <ImageBrush Stretch="Fill" ImageSource="icons/server.png"/>
                        </Rectangle.OpacityMask>
                    </Rectangle>
                </Grid>
            </controls:PivotItem>

            <!--Pivot item two-->
            <controls:PivotItem Header="projects" DataContext="{Binding Projects}">
                <ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding ActiveItem, Mode=TwoWay}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <local:ProjectItemControl x:Name="ProjectInfo"/>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>
        </controls:Pivot>
        <ProgressBar x:Name="progressBar" Height="10" VerticalAlignment="Top" Opacity="0"/>
    </Grid>
</phone:PhoneApplicationPage>